using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using FinanceStats.Common;
using System.Data;

namespace FinanceStats.DAL
{
    public static class CommonDAO
    {

        public static DateTime GetFirstEnterenceDate(long userID)
        {
            string selectSQL = String.Format("SELECT MIN(DATE) FROM ACS.DBO.USEROUTCOME WHERE USERID = {0}", userID);
            SqlDatabase db = new SqlDatabase(AppSettingsHelper.GetWebConfigValue(Constants.ACSConnectionString));
            DateTime res = (DateTime)db.ExecuteScalar(CommandType.Text, selectSQL);
            return res;
        }

        public static DateTime GetLastEnterenceDate(long userID)
        {
            string selectSQL = String.Format("SELECT MAX(DATE) FROM ACS.DBO.USEROUTCOME WHERE USERID = {0}", userID);
            SqlDatabase db = new SqlDatabase(AppSettingsHelper.GetWebConfigValue(Constants.ACSConnectionString));
            DateTime res = (DateTime)db.ExecuteScalar(CommandType.Text, selectSQL);
            return res;
        }
    }
}
